package com.call.data;

import java.util.Hashtable;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.BaseColumns;
import android.util.Log;

import com.call.Constants;

public class MissCallData extends ListByDatabase{

	public static class TableColumns implements BaseColumns
	{
		public static final String CallStartTime = "CallStartTime";
		public static final String CallNumber = "CallNumber";
		public static final String CallDuration = "CallDuration";
	}
	public static class DatabaseHelper extends SQLiteOpenHelper 
	{

		private String m_strTableName;
        public DatabaseHelper(Context context, String tableName) {
            super(context, Constants.DATABASE_NAME, null, Constants.DATABASE_VERSION);
            m_strTableName = tableName;
        }
        
        @Override
        public void onCreate(SQLiteDatabase db) {
        	db.execSQL("DROP TABLE IF EXISTS " + m_strTableName);
            db.execSQL("CREATE TABLE " + m_strTableName + " ("
            		+ TableColumns._ID + " INTEGER PRIMARY KEY,"
                    + TableColumns.CallDuration + " INTEGER,"
                    + TableColumns.CallNumber + " TEXT,"
                    + TableColumns.CallStartTime + " LONG" 
                    + ");");
        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            Log.w(Constants.Tag, "Upgrading database from version " + oldVersion + " to "
                    + newVersion + ", which will destroy all old data");
            db.execSQL("DROP TABLE IF EXISTS " + m_strTableName);
            onCreate(db);
        }
    }
	
	public MissCallData(SQLiteOpenHelper objDBHelper, String strTableName) 
	{
		super(objDBHelper, strTableName);
	}
	
	public static MissCallData GetMissCallData(Context context,String strTableName)
	{
		DatabaseHelper dbHelper = new DatabaseHelper(context, strTableName);
		return new MissCallData(dbHelper, strTableName);
	}

}
